<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>


<style type="text/css">
    .l-table-edit {font-size: 12px;margin: auto;}
 	.l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    .l-verify-tip{ left:230px; top:120px;}
    .error{color:red}
</style>


<form name="saveForm" method="post" action="/misc/hotel/saveRoom.htm" id="saveForm">
<input type="hidden" id="hotel" name="hotel" value="${hotel }"/>
<input name="id" type="hidden" id="id" value="${room.id}" />
	<table cellpadding="0" cellspacing="0" class="l-table-edit">
		<tr>
			<td align="right" class="l-table-edit-td">
				名称:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="name" type="text" id="name" value="${room.name}" ltype="text" validate="{required:true,minlength:2,maxlength:50}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				床型:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="bedType" type="text" id="bedType" value="${room.bedType}" ltype="text" validate="{required:true,maxlength:20}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
		</tr>
		<tr>
			<td align="right" class="l-table-edit-td">
				总房间数:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="amount" type="text" id="amount" value="${room.amount}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				剩余房间数:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="lamount" type="text" id="lamount" value="${room.lamount}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
		</tr>
		<tr>
			<td align="right" class="l-table-edit-td">
				市场价格:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="priceMarket" type="text" id="priceMarket" value="${room.priceMarket}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				最低价格:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="priceMin" type="text" id="priceMin" value="${room.priceMin}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
		</tr>
		<tr>
			<td align="right" class="l-table-edit-td">
				普通价格:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="priceComA" type="text" id="priceComA" value="${room.priceComA}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				提前预定天数:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="befores" type="text" id="befores" value="${room.befores}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			
		</tr>
		<tr>
			<td align="right" class="l-table-edit-td" valign="top">
				普通价是否可用:
			</td>
			<td align="left" class="l-table-edit-td">
				<input id="needCard1" type="radio" name="priceComHas" <c:if test="${room.priceComHas}">checked="checked"</c:if> value="1" checked="checked" />
				<label for="payFrom1">
					是
				</label>
				<input id="needCard2" type="radio" name="priceComHas" <c:if test="${!room.priceComHas}">checked="checked"</c:if> value="0" />
				<label for="payFrom2">
					否
				</label>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">所属公司:</td>
            <td align="left" class="l-table-edit-td"> 
            	<%-- <select name="company" id="company">
					<option value="">请选择</option>
					<c:forEach items="${companyModel.list}" var="comp">
						<option value="${comp.id}"
						<c:if test="${room.company==comp.id }">SELECTED</c:if>
						>${comp.name}</option>
					</c:forEach>
				</select> --%>
				<%@include file="../company/companyName.jsp"%>
            </td>
			<td align="left"></td>
		</tr>
		<tr>
            <td align="right" class="l-table-edit-td">简介:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea"  id="desc" name="desc" style="width:600px" validate="{required:true}">${room.desc}</textarea>
            </td>
        </tr>
	</table>
	<br />
	<input type="submit" value="保存" id="Button1" class="l-button l-button-submit" />
	<input type="button" value="取消" class="l-button l-button-test" onclick="javascript:parent.dialog_ae.close();"/>
</form>


<script type="text/javascript">
$(function() {
	
	var toolbars = [['FullScreen','Source','Link','Unlink','Preview','InsertImage','Emotion','Spechars','Bold','Italic',
			'Underline','StrikeThrough','ForeColor','BackColor','JustifyLeft','JustifyCenter','JustifyRight','JustifyJustify',
			'Paragraph','FontFamily','FontSize','ImageNone','ImageLeft','ImageRight','ImageCenter']];
	var initialStyle = 'body{font-family:"宋体";font-size:12px;}';
	var initArgus = {
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false
	}
	
	var desc_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'desc'
	});
	desc_editor.render("desc");
    
    $.metadata.setType("attr", "validate");
	$("#saveForm").validate({
		 errorPlacement: function (lable, element){
             if (element.hasClass("l-textarea")){
                 element.ligerTip({ content: lable.html(), target: element[0] }); 
             }else if (element.hasClass("l-text-field")){
                 element.parent().ligerTip({ content: lable.html(), target: element[0] });
             }else{
                 lable.appendTo(element.parents("td:first").next("td"));
             }
         },
         success: function (lable){
             lable.ligerHideTip();
             lable.remove();
         },
		submitHandler : function(form) {
        	 $(form).ajaxSubmit({
				dataType : 'text',
				cache : false,
				success : function(data) {
					if(IsNull(data)){
						alert("上传图片失败，请重新上传！");
					}else{
						parent.grid_ae.loadData();
						parent.dialog_ae.close();
					}
					
				},
				error : function(err) {
				//	alert(err);
				}
			});
			return false;
			
			
		}
	});
//	$("#form1").ligerForm();
});

function uploadImg(self,imagex){
	var filepath = $(self).val();
	var extStart = filepath.lastIndexOf(".");
	var ext = filepath.substring(extStart, filepath.length).toUpperCase();
	if (ext != ".PNG" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
		alert("图片限于png,jpeg,jpg,gif格式");
		return;
	}
	$("#upload_img_form"+imagex).ajaxSubmit({
		dataType : 'json',
		cache : false,
		success : function(data) {
			$("#image"+imagex).val(data.imageServer+data.imageUrl);
		},
		error : function(err) {
			alert(err);
		}
	});
	return false;
}

function previewImg(imageId){
	var img_url = $("#"+imageId).val();
	if(!IsNull(img_url)){
		window.open(img_url);
	}else{
		alert("没有图片，请上传！");
	}
}
</script>
